---
title: "Get Content After Matching"
date: 2019-7-29
categories:
- regex
tags:
---

<div id="content">
<blockquote>
<p>
<a href="https://stackoverflow.com/questions/10358547/how-to-grep-for-contents-after-pattern">https://stackoverflow.com/questions/10358547/how-to-grep-for-contents-after-pattern</a>
</p>
</blockquote>
<div class="org-src-container">
<pre class="src src-sh">grep -oP <span style="font-style: italic;">'(?&lt;=potato: ).*'</span> file.txt
</pre>
</div>
<p>
(?&lt;=pattern) 零宽度正预测先行断言。它断言自身出现的位置的[后面]能匹配表达式exp。
即 'potato: ' 的后面需要能匹配到 '.*'
</p>
</div>
<div class="status" id="postamble">
<p class="date">Date: 2019-7-29</p>
<p class="author">Author: gdme1320</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
